package io.zhengsh.vvip.leetcode;

import java.util.Arrays;
import java.util.HashSet;

class Solution1 {
    public boolean containsDuplicate(int[] nums) {
        Arrays.sort(nums);
        for (int i = 1; i < nums.length; i++) {
            if (nums[i -1 ] == nums[i]) {
                return true;
            }
        }
        return false;
    }
}

class Solution122 {
    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> set = new HashSet<>(nums.length);
        for (int i = 1; i < nums.length; i++) {
            if (!set.add(nums[i])) {
                return true;
            }
        }
        return false;
    }
}